package com.smartwebee.android.blespp.hospital.fragment;


import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.smartwebee.android.blespp.R;
import com.smartwebee.android.blespp.databinding.FragmentSelfTestBinding;
import com.smartwebee.android.blespp.hospital.selftest.SelfTestActivity;

/**
 * A simple {@link Fragment} subclass.
 */
public class SelfTestFragment extends Fragment {

    public static final String INTENT_TITLE = "intent_title";
    public static final String TYPE1 = "KUJALA评分量表";
    public static final String TYPE2 = "WOMAC骨性关节炎指数评分表";
    public static final String TYPE3 = "膝关节HSS评分表";
    public static final String TYPE4 = "膝关节LYSHOLM评分表";
    FragmentSelfTestBinding binding;
    public SelfTestFragment() {
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        binding = DataBindingUtil.inflate(inflater, R.layout.fragment_self_test, container, false);
        return binding.getRoot();
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        binding.clayoutToChart1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                toSelfTestActivity(TYPE1);
            }
        });
        binding.clayoutToChart2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                toSelfTestActivity(TYPE2);
            }
        });
        binding.clayoutToChart3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                toSelfTestActivity(TYPE3);
            }
        });
        binding.clayoutToChart4.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                toSelfTestActivity(TYPE4);
            }
        });
    }

    public void toSelfTestActivity(String title) {
        Intent intent = new Intent(getActivity(), SelfTestActivity.class);
        intent.putExtra(INTENT_TITLE, title);
        startActivity(intent);
    }
}
